# file listing
# (c) 2008-2009 NIXON Development Corporation.

import wx
import common

class listingPanel(wx.Panel):
	lstCrumbs = []
	
	def __init__(self, prnt, blLocal):
		wx.Panel.__init__(self, prnt.splitBrowser)
		self.hdlFrame = prnt
		self.blLocal = blLocal
		self.iconPackage = prnt.iconPackage
		
		sizer = wx.BoxSizer(wx.VERTICAL)
		
		self.swCrumbs = wx.ScrolledWindow(self)
		self.swCrumbs.SetScrollRate(1, 0)
		sizer.Add(self.swCrumbs, 0, wx.EXPAND)
		
		self.crumbSizer = wx.BoxSizer(wx.HORIZONTAL)
		self.swCrumbs.SetSizer(self.crumbSizer)
		
		self.lstListing = common.extListCtrl(self, (-1,-1), \
			wx.LC_REPORT | wx.LC_EDIT_LABELS, self)
		
		self.lstListing.InsertColumn(1, 'Name')
		self.lstListing.InsertColumn(2, 'Size')
		self.lstListing.InsertColumn(3, 'Changed')
			
		sizer.Add(self.lstListing, 1, wx.EXPAND)
		
		self.SetSizer(sizer)
		
	def addCrumb(self, label):
		self.lstCrumbs.append(breadcrumb(self.swCrumbs, label, self.iconPackage))
		ls = len(self.lstCrumbs)
		self.swCrumbs.SetVirtualSize((ls * 128, -1))
		self.crumbSizer.Add(self.lstCrumbs[-1], 0, wx.EXPAND)
		
	def addListBox(self, label, local=False):
		self.addCrumb(label)

	def doThrobber(self, bl=True):
		pass
		
class breadcrumb(wx.BoxSizer):
	def __init__(self, prnt, label, iconPackage):
		wx.BoxSizer.__init__(self, wx.HORIZONTAL)
		#self.SetBackgroundColour((255,255,255))
		
		img = wx.StaticBitmap(prnt, bitmap=iconPackage.iconSmallDir)
		self.Add(img, 0, wx.LEFT | wx.TOP | wx.BOTTOM, 2)

		st = wx.StaticText(prnt, label=label)
		self.Add(st, 0, wx.EXPAND | wx.ALL | wx.ALIGN_CENTER_VERTICAL, 4)
		
		arrow = wx.StaticBitmap(prnt, bitmap=iconPackage.iconNextDir)
		self.Add(arrow, 0, wx.ALL | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 4)